/*==============================================================================
           Copyright (c) 2013 Moritz Hader, Marcel Schrder
            All Rights Reserved.

	@file  HeimdallNative3DObject.h

	@brief This header provides the class-definitions of the HeimdallNative3DObject.
	The 3DObject capsulates the mesh and surface-data received from the java-instance
	of this program and provides functionality to create the corresponding
	OpenGL-information (like matrix-data)
   
   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
================================================================================*/

#ifndef _HEIMDALLNATIVE3DOBJECT_LIBRARY__
#define _HEIMDALLNATIVE3DOBJECT_LIBRARY__

#include <jni.h>
#include <egl/HeimdallMath.h>
#include <engine/HeimdallLinkable.h>

//Forward Declaration
class HeimdallNativeMesh;
class HeimdallNativeSurface;
class ShaderManagementUnit;

static const H3DVector lightPosV = {0.0f,10.0f,5.0f};



class HeimdallNative3DObject: public HeimdallLinkable{
private:
	HeimdallNativeMesh* nativeMesh;
	HeimdallNativeSurface* nativeSurface;

	//NOTE: Not the best solution. It actually matters whether we apply rotation before translation or the other way around.
	//For now, we'll chose a fixed solution that calculates the rotation first, then the translation, then the scale
	H3DVector nativePosition;
	H3DVector nativeScale;
	H3DVector nativeRotation;

	bool isFinalized;

	int markerID;

public:
	HeimdallNative3DObject();
	~HeimdallNative3DObject();

	//void loadJavaObject(JNIEnv* env, jobject nativeObj, int index);
	void loadJavaObject(JNIEnv* env, jobject nativeObj);
	void setupObject();
	void draw(ShaderManagementUnit* smu, H44DMatrix localModel, H44DMatrix projection);

	void updatePosition(JNIEnv* env, jobject nativeObj,jclass hdClass);
	void updateScale(JNIEnv* env, jobject nativeObj,jclass hdClass);
	void updateRotation(JNIEnv* env, jobject nativeObj,jclass hdClass);

	int getMarkerID();

};

#endif
